package galleryviewer;
import javafx.scene.image.ImageView;
import javafx.scene.input.MouseEvent;
import javafx.scene.paint.Color;
import javafx.scene.Group;


/**
 * @author jaccus, SiMet
 */
 
 public class ControlButton extends ImageView{
     public var name : String;
     
     public var color : Color;
     
     public var highlightColor : Color;
     
     public override var opacity = bind if(Controllers.selectedFilter.equals(name)) 0.4 else 1.0;
     
    
     public override var onMouseClicked = function(e:MouseEvent):Void {
		println("clicked inside a button at {e.x}, {e.y}");
			
		//clicked at the same button again so remove the filter
		if(Controllers.selectedFilter == name) {
		    Controllers.selectedFilter = null;
		
		//if that's another filter button - change the filter
		} else {
			Controllers.selectedFilter = name;
		}
	
	
		Controllers.currentHighlightColor = highlightColor;

		//and refresh the color of local objects
		for (local in Local.allLocals) {
		    local.refreshColor();
		}
     }
     
     override function toString() : String {
         return name;
     }
 }